package cn.sdhuijin.healthexam.activity;

import android.content.Intent;
import android.os.Bundle;
import android.util.Log;
import android.view.View;
import android.view.View.OnClickListener;
import android.view.Window;
import cn.sdhuijin.healthexam.ExitApplication;
import cn.sdhuijin.healthexam.R;
import cn.sdhuijin.healthexam.control.AbstractControlActivity;
import cn.sdhuijin.healthexam.util.Constants;

/**
 * 新建人员档案
 * 
 * @author houyuchun
 * 
 */
public class EditPersonDocThirdActivity extends AbstractControlActivity
		implements OnClickListener {

	// 创建日期ID
	private String createDate;
	// 残疾情况
	private int[] checkCanjiIds = { R.id.check_canji_shili,
			R.id.check_canji_tingli, R.id.check_canji_yuyan,
			R.id.check_canji_zhiti, R.id.check_canji_zhili,
			R.id.check_canji_jingshen };

	@Override
	protected void onCreate(Bundle savedInstanceState) {
		super.onCreate(savedInstanceState);
		// 去掉标题
		this.requestWindowFeature(Window.FEATURE_NO_TITLE);
		setContentView(R.layout.activity_edit_doc_third);
		ExitApplication.getInstance().addActivity(this);

		Intent intent = getIntent();
		// 创建日期ID
		Bundle bundle = intent.getBundleExtra("bundle");
		if (bundle != null) {
			createDate = bundle.getString("createDate");
		}
		setCurrentEditUserName(createDate);
		addEditTextView(R.id.edt_shoushu_mingcheng1, "手术名称1");
		addEditTextView(R.id.edt_shoushu_riqi1, "手术日期1");
		addEditTextView(R.id.edt_shoushu_mingcheng2, "手术名称2");
		addEditTextView(R.id.edt_shoushu_riqi2, "手术日期2");

		addEditTextView(R.id.edt_waishang_mingcheng1, "外伤名称1");
		addEditTextView(R.id.edt_waishang_riqi1, "外伤日期1");
		addEditTextView(R.id.edt_waishang_mingcheng2, "外伤名称2");
		addEditTextView(R.id.edt_waishang_riqi2, "外伤日期2");

		addEditTextView(R.id.edt_shuxue_yuanyin1, "输血原因1");
		addEditTextView(R.id.edt_shuxue_riqi1, "输血日期1");
		addEditTextView(R.id.edt_shuxue_yuanyin2, "输血原因2");
		addEditTextView(R.id.edt_shuxue_riqi2, "输血日期2");

		addEditTextView(R.id.edt_yichuanbing, "遗传病名称");

		addCheckBoxView(checkCanjiIds, "残疾情况");

		addEditTextView(R.id.edt_canji_qita, "其他残疾");

		// Properties文件路径
		controlManager.setPropertiesPath(Constants.PROPERTIES_PATH + createDate
				+ ".txt");
		Log.i(EditPersonDocThirdActivity.class.getSimpleName(), "文件路径： "
				+ Constants.PROPERTIES_PATH + createDate + ".txt");
		controlManager.toControl();

		setEditTextListener(R.id.edt_shoushu_riqi1);
		setEditTextListener(R.id.edt_shoushu_riqi2);
		setEditTextListener(R.id.edt_waishang_riqi1);
		setEditTextListener(R.id.edt_waishang_riqi2);
		setEditTextListener(R.id.edt_shuxue_riqi1);
		setEditTextListener(R.id.edt_shuxue_riqi2);
		setButtonListener(this, R.id.btn_next, R.id.btn_previous);
	}

	/**
	 * 按钮点击处理事件
	 */
	@Override
	public void onClick(View arg0) {
		Intent intent = new Intent();
		Bundle bundle = new Bundle();
		// 获取点击按钮
		int id = (Integer) arg0.getId();
		switch (id) {
		case R.id.btn_previous:
			controlManager.toProperties();
			bundle.putString("createDate", createDate);
			// 创建日期
			intent.putExtra("bundle", bundle);
			// 前一页按钮
			intent.setClass(this, EditPersonDocSecondActivity.class);
			startActivity(intent);
			this.finish();
			break;
		case R.id.btn_next:
			// 保存当前信息到Bean
			controlManager.toProperties();
			bundle.putString("createDate", createDate);
			// 创建日期
			intent.putExtra("bundle", bundle);
			// 前一页按钮
			intent.setClass(this, EditPersonDocForthActivity.class);
			startActivity(intent);
			this.finish();
			break;
		default:
			break;
		}
	}
}
